<!DOCTYPE html>
<%@page import="cn.school.entity.Grade"%>
<%@page import="java.util.List"%>
<%@page import="cn.school.service.GradeService"%>
<html lang="en">
<head>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在此处插入标题</title>
<script src="js/jquery-3.4.1.min.js"></script>
<!-- <script>
 $(function(){
	 $("#telephone").blur(function(){
		 if(this.value==""){
			 return false;
		 }
		 $.get("checkTeleServlet",{tele:$(this).val()},function(data){
			 if(data=="true"){
				  alert("此电话已经被注册了");
			  }else{
				  alert("此电话可以使用");
			  }
			 
		 },"text").fail(function(e){
			alert("出错了："); 
		 });
	 });
	 
	 //gradeid
	 $.get("gradeAjaxServlet",function(data){
		 var g=$("#gradeid");
		 $.each(data,function(i,d){
			 g.append(new Option(d.gname,d.id));
			 //g.append("<option value=''></option>");
		 });
	 });
 });
</script> -->
<script>
function createAjax(){
   if(window.XMLHttpRequest)
	   return new XMLHttpRequest();
   
   return new ActiveXObject("Microsoft.XMLHTTP");  
}
function checkTele(t){
	  if(t.value=="")
		  {
		  	return false;
		  }
	  //发送ajax请求验证
	  var xhr=createAjax();
	  xhr.onreadystatechange=function(){
		  if(xhr.readyState==4&&xhr.status==200){
			 // alert(xhr.getAllResponseHeaders());
			 // console.log(xhr.getAllResponseHeaders());
			  var str=xhr.responseText;
			  if(str=="true"){
				  alert("此电话已经被注册了");
			  }else{
				  alert("此电话可以使用");
			  }
		  }
	  }
	  xhr.open("GET","checkTeleServlet?tele="+t.value,true);
	  xhr.send(null);
  }
</script>
</head>
<body>
<form action="doAddStudent.jsp" method="post" enctype="multipart/form-data">
<p>

	<label>姓名</label>
	<input type="text"   name="sname"/>
	
	</p>
	<p>
	<label>性别</label>
	<input type="radio" checked="checked"  name="sex" value="男"/>男
	<input type="radio"  name="sex" value="女"/>女
	</p>
	<p>
	<label>电话</label>
	<input type="text"   name="telephone" id="telephone" onblur="checkTele(this)"/>
	</p>
	<p>
	<label>qq</label>
	<input type="text"   name="qq"/>
	</p>
	<p>
	<label>微信</label>
	<input type="text"   name="wechat"/>
	</p>
	<p>
	<label>年级</label>
	
	<select   name="gradeid" id="gradeid">
	
	</select>
	</p>
	<p>
	<label>入学日期</label>
	<input type="text"   name="enterdate"/>
	</p>
	<p>
	<label>来自哪个城市</label>
	<input type="text"   name="fromcity"/>
	</p>
	<p>
	<label>生日</label>
	<input type="text"   name="birthday"/>
	</p>
	<p>
	<label>地址</label>
	<input type="text"   name="address"/>
	</p>
	<p>
	<label>密码</label>
	<input type="text"   name="pass"/>
	</p>
	<p>
	<label>身份证照片</label>
	<input type="file"   name="idcardpic" accept="jpg|gif|png"/>
	</p>
	<p>
    <input type="submit" value="新增"/>
   </p>
</form>

</body>
</html>